<%--
    Document   : newfood
    Created on : Nov 11, 2011, 10:24:21 AM
    Author     : Venus
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.util.*, java.text.NumberFormat,Beans.NgonNgu,Beans.ThamSoHT, Models.ThamSoHT_Model, Models.NhomMA_Model, Models.MonAn_Model, Models.DonViTinh_Model, Models.TienTe_Model"%>
<script type="text/javascript">
        function keypress(e){
            //Hàm dùng để ngăn người dùng nhập các ký tự khác ký tự số vào TextBox
            var keypressed = null;
            if (window.event)
            {
                keypressed = window.event.keyCode; //IE
            }
            else
            {
                keypressed = e.which; //NON-IE, Standard
            }
            if (keypressed < 48 || keypressed > 57 )
            { //CharCode của 0 là 48 (Theo bảng mã ASCII)
                //CharCode của 9 là 57 (Theo bảng mã ASCII)
                if (keypressed == 8 || keypressed == 127 || keypressed == 46 )
                {//Phím Delete và Phím Back
                    return;
                }
                return false;
            }
        }


</script>
<%
            int langid = (Integer) session.getAttribute("langid"); // ngôn ngữ hiện tại
            String dsts = " 'updatefood', 'newfood', 'save', 'addmore', 'choosefile', 'rightmsg', 'chktientemsg', 'notice', 'checkunitmsg', 'checksubmitmsg', 'foodgroups', 'foodname', 'abbreviation', 'description', 'image', 'unit', 'price' ";
            ThamSoHT[] mdsts = ThamSoHT_Model.DSThamSo(dsts, langid); // mảng chứa các tham số của trang này.

            String abbreviation = mdsts[0].getTenTS();
            String addmore = mdsts[1].getTenTS();
            String checksubmitmsg = mdsts[2].getTenTS();
            String checkunitmsg = mdsts[3].getTenTS();
            String chktientemsg = mdsts[4].getTenTS();
            String choosefile = mdsts[5].getTenTS();
            String description = mdsts[6].getTenTS();
            String foodgroups = mdsts[7].getTenTS();
            String foodname = mdsts[8].getTenTS();
            String image = mdsts[9].getTenTS();
            String newfood = mdsts[10].getTenTS();
            String notice = mdsts[11].getTenTS();
            String price = mdsts[12].getTenTS();
            String rightmsg = mdsts[13].getTenTS();
            String save = mdsts[14].getTenTS();
            String unit = mdsts[15].getTenTS();
            String updatefood = mdsts[16].getTenTS();

            String msgright = notice + "/" + rightmsg;
            String msgsubmit = notice + "/" + checksubmitmsg;
            String msgcheckunit = notice + "/" + checkunitmsg;
            String msgcheckcurrency = notice + "/" + chktientemsg;

            Vector vDSNMA = (Vector) request.getAttribute("DSNMA");
            Vector v = (Vector) request.getAttribute("detail");
            Vector vgia = (Vector) request.getAttribute("vgia");
            String mama = (String) request.getAttribute("mama");
            NumberFormat nf = NumberFormat.getNumberInstance(Locale.FRENCH);
%>

<div class="bloc" style="  margin-top: 0px; ">
    <div class="title">
        
        <%=updatefood%>
    </div>
    <div class="content">
        <form name="addFood" class="<%=msgsubmit %>" id="<%=msgcheckcurrency %>" dir="<%=msgright%>"  lang="<%=msgcheckunit %>" onsubmit="return CheckSubmit(this.className, this.lang, this.id, this.dir)" action="../MonAn_Controller?action=Edit&mama=<%=mama%>" enctype="multipart/form-data" method="post">
            <%
                for(int i=0; i<v.size(); i++){
                    Beans.MonAn ma = (Beans.MonAn) v.elementAt(i); %>
            <div style=" float: left; width: 37%; margin-left: 20px; margin-top: 0px; margin-bottom: 5px;">
            <div style="width: 110px; float: left; margin-left: 5px; "><label><%=foodgroups %></label></div>
            <select name="nhommonan" style=" width: 200px; margin-bottom: 11px;">
                <option value="<%=ma.getMaNMA()%>"><%=NhomMA_Model.LayTenNhomMA(ma.getMaNMA(), langid)  %></option>
                <%  
                    for(int y=0; y< vDSNMA.size(); y++){
                        Beans.NhomMA nma = (Beans.NhomMA) vDSNMA.elementAt(y);
                %>
                <option value="<%=nma.getMaNMA() %>"><%=nma.getTenNMA() %></option>
                <%  }
                %>
            </select><br />
            <div style="width: 110px; float: left; margin-left: 5px; "><label><%=foodname %></label></div>
            <input type="text" style=" width: 200px; margin-bottom: 11px;" value="<%=ma.getTenMA()  %>" class="text" name="tenmonan"/><br />
            <div style="width: 110px; float: left; margin-left: 5px; "><label><%=abbreviation %></label></div>
            <input type="text" style=" width: 200px; margin-bottom: 11px;" value="<%=ma.getTenMAVT() %>" class="text" name="tenviettat"/><br />
            <div style="width: 110px; float: left; margin-left: 5px; "><label><%=description %></label></div>
            <textarea class="textarea" style=" margin-bottom: 11px;" cols="22" rows="2"  name="mota"><%=ma.getMoTa() %></textarea><br />
            <div style="width: 110px; float: left; margin-left: 5px; "><label><%=image %></label></div>
            <div id="uniform-file" class="uploader">
                <input id="imageUpload" type="file" size="15" name="Image" id="Image" onchange="Upload(this.value)" style="opacity: 0; ">
                <span class="filename" style="-moz-user-select: none; margin-top: -24px; color: #131313; max-width: 180px;"><%=ma.getTenMA() %></span>
                <span class="action" style="-moz-user-select: none;"><%=choosefile%></span>
            </div><br />
            <input type="submit" class="button" style=" margin-left: 115px; margin-top: 10px; margin-bottom: 5px;" value="<%=save%>">
            </div>
            <div style="float: left;">
                <img style=" width: 200px; height: 190px;" alt="" src="../images/foodimages/<%=MonAn_Model.LayTenHinhAnh(ma.getMaMA())%>">
            </div>

            <table style=" width: 36%; margin-top: 15px; padding-left: 25px;" >
                <thead>
                    <tr>
                        <th style="width: 35%; border: none; background: none; padding-bottom: 15px;"><%=unit %></th>
                        <th style="width: 50%; border: none; background: none; padding-bottom: 15px;"><%=price %>
                            <%  String kyhieu = TienTe_Model.LayKyHieuTT(langid); %>
                            <a href="#" style=" margin-left: 15px;" name="<%=kyhieu %>" id="<%=msgcheckunit %>" dir="<%=msgcheckcurrency %>" onclick="Addmoredvt(this.name, this.id, this.dir)"><%=addmore%></a>
                        </th>
                    </tr>
                </thead>
                <tbody id="dvt">
                    <%
                        for(int t=0; t<vgia.size(); t++){
                            Beans.Gia g = (Beans.Gia) vgia.elementAt(t);%>
                    <tr>
                        <td style="border: none; background: none;">
                            <input type="text" style=" width: 100px; margin-bottom: 11px;" value="<%=DonViTinh_Model.LayTenDVT(g.getMaDVT(), langid)  %>" alt="<%=msgcheckunit %>" onchange="CheckDVT(this.value, this.alt)" class="text" name="donvitinh"/>
                        </td>
                        <td style="border: none; background: none;">
                            <input type="text" style=" width: 100px; margin-bottom: 11px;" value="<%=g.getGia() %>" alt="<%=msgcheckcurrency %>"  onkeypress="return keypress(event)" onchange="CheckTienTe(this.alt)" class="text" name="gia"/>
                            <%=TienTe_Model.LayKyHieuTT(langid) %>
                        </td>
                    </tr>
                    <%  }
                    %>                    
                <input type="hidden" id="checksubmit" value="true">
                <input type="hidden" id="checkcurrency" value="true">
                </tbody>
            </table>        
            <%  } %>
        </form>
    </div>
</div>
<div id="foodlang" style=" width: 49%; overflow: hidden; " >
</div>